/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lab5_Test.Test4;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author THIEN
 */
public class ThreadOne extends MyThread {

    public ThreadOne(Data d) {
        super(d);
    }

    @Override
    public void run() {
        this.getData();

    }
    /*
     * get all data
     */

    public void getData() {
        int i = 0;
        while (i < 5) {
            synchronized (this.d) {
                if (!d.flag) {
                    String[] data = d.getData();
                    d.temp = data[i];
                    d.flag = true;
                }
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException ex) {
                //Logger.getLogger(ThreadOne.class.getName()).log(Level.SEVERE, null, ex);
            }

            i++;
        }


    }
}
